home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / C / MATV.ZIP / REDIR.H < prev   
Encoding:
C/C++ Source or Header  |  1993-10-10  |  599 b   |  24 lines

  1. #include <iostream.h>
  2. #include <fcntl.h>
  3. #include <sys\stat.h>
  4. #include <io.h>
  5. #include <stdlib.h>
  6.  
  7. // send stdout to a file
  8. class Redirector
  9. {
  10.    private :
  11.    int fout;      // handle for file
  12.    int oldstdout; // handle for old stdout
  13.    int onoff;     // indicator that it has been redirected
  14.    
  15.    public :
  16.    Redirector(void) { fout = 1; oldstdout = 0; onoff = 0; }
  17.    Redirector(char *fid) { fout = 1; oldstdout = 0; onoff = 0; rdopen(fid); }
  18.    ~ Redirector(void) { if (onoff == 1) rdclose(); }
  19.    void rdopen(char *fid = "stdout.dat");
  20.    void rdclose(void);
  21.    
  22. };
  23.  
  24.